<?php


namespace app\api\controller\xiluedu;


use app\common\controller\Api;
use app\common\model\xiluedu\Config as ConfigModel;

class Config extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function config()
    {
        $name = $this->request->param('name', null);
        $config = ConfigModel::getMyConfig($name);
        if (isset($config['custom_qrcode']) && $config['custom_qrcode']) {
            $config['custom_qrcode'] = cdnurl($config['custom_qrcode'], true);
        }
        $this->success('查询成功', $config);
    }

    public function get_image()
    {
        $field = $this->request->param('field', null);
        $name = $this->request->param('name', null);
        $config = ConfigModel::getMyConfig($name);
        $image = isset($config[$field]) ? $config[$field] : '';
        $this->success('查询成功', ['image' => cdnurl($image, true)]);
    }
}
